package com.water.app.mapper;

import com.water.app.Goods;
import com.water.app.ShoppingCart;
import com.water.app.address;
import com.water.app.cartMoney;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface shoppingMapper {

    public address selectAddressById(Integer id);

    //一个一个的添加商品数量,如果商品选购已经被创建
    public int addGoodsSingleById(int userId,int goodsId);

    //一个一个的添加商品数量,如果商品选购未被创建
    public int addNewGoodsSingleById(int userId,int goodsId);

    //查询购物车是否存在
    public int selectCartIsExist(int userId,int goodsId);

    //一个一个删除商品，如果商品数量大于1
    public int reduceGoodsSingleById(int userId, int goodsId);

    //查询对应的商品数量
    public int selectCartGoodsNumber(int userId, int goodsId);

    //直接删除一行商品，如果商品数量变为0
    public int deleteGoodsSingleById(int userId, int goodsId);

    //清空购物车
    public void clearCartById(int userId);

    //判断是否清空了购物车
    public int cartIsClear(int userId);

    //随意更改商品数量
    public int updateGoodsArbitrary(int goodsId, int number);

    //一件一件计算商品数量

    //通过userId确定cart里面的商品数量，通过goodsId查询商品价格，进而一个个计算总价格
    @MapKey("goodsId")
    public List<Map<Integer, Double>> countGoodsPriceOneByOne(@Param("userId") int userId);

    public int updateTotals(double total, int userId);

    public int TotalsIsExistByUserId(int userId);

    public int insertTotals(double total, int userId);

    public double selectUserMoney(int userId);

    public  int decreaseUserMoney(int userId, double total);

    public int increaseUserMoney(double total,int userId);

    int selectCount(int goodsId);

    void decreaseGoodsCount(int goodsId);

    public int buyerRecords(int userId, double total);

    public int sellerRecords(Map<Integer,Double> list);

    public int selectGoodsCountById(int goodsId);

    public int selectVersionById(int goodsId);

    public int insertCart(int userId, int goodsId, int number);

    public int updateCartArbitrary(int userId,int goodsId, int number);

    public List<Goods> showCart(int userId);

    public double selectGoodsMoney(int goodsId);

    public int selectUserIdByGoodsId(int goodsId);

    public Goods selectGoodsById(int goodsId);

    public int intoOrders(Goods goods,int userId,int number);
}
